package com.cskaoyan.javase.controlflow.loop4.whiles;

/**
 * @description: 叠纸
 * @author: wuguidong@cskaoyan.onaliyun.com
 **/

/**
 * - 珠峰的高度是8848m，假设有一张足够大可折叠的纸张，初始厚度是0.01m，
 *   - 求解这张纸折叠多少次，纸张的厚度开始超过珠峰？
 *
 *
 */
public class Demo2 {
    public static void main(String[] args) {

        int high = 1;
        int maxHigh = 884800;
        int count = 0;
        while (high < maxHigh) {
            //叠纸一次 厚度乘以2
            high *= 2;
            count++;
        }
        System.out.println("需要折叠:" + count + "次");

        System.out.println("---------------------------------");
        //使用for循环替代这个for
        int count2 = 0;
        for (int i = 1; i < 884800; i = i * 2) {
            count2++;
        }
        System.out.println("需要折叠:" + count2 + "次");
    }
}
